package com.fesine.ch01.lesson06;

/**
 * Created by Fesine on 2016/6/27.
 */
public class TestSleep extends Thread {
    //@Override
    //public void run() {
    //    try {
    //        System.out.println("run threadName=" + this.currentThread().getName()+" begin");
    //        Thread.sleep(2000);
    //        System.out.println("run threadName=" + this.currentThread().getName()+" end");
    //    } catch (InterruptedException e) {
    //        e.printStackTrace();
    //    }
    //}


    @Override
    public void run() {
            try {
                System.out.println("run threadName=" + this.currentThread().getName()+" begin="
                        + System.currentTimeMillis());
                Thread.sleep(2000);
                System.out.println("run threadName=" + this.currentThread().getName()+" end="
                        + System.currentTimeMillis());
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
    }

    public static void main(String[] args) {
        TestSleep testSleep = new TestSleep();
        Thread runThread = Thread.currentThread();
        System.out.println(runThread.getName()+" " + runThread.getId());
        System.out.println("begin= " +System.currentTimeMillis());
        //testSleep.run();
        testSleep.start();
        System.out.println("end= " +System.currentTimeMillis());
    }
}
